<?php $control->renderView('booking_home', array()); ?>
<?php
$cart = new BCart();
$view = $cart->getView(array('itemData' => array('paymentStatus' => bcart::Payment_Status_Not_Paid)));
$totalCount = count($view);
?>

<script type="text/javascript">
    $(document).ready(function() {
        $("#selectAll").click(function() {
            if ($(this).attr("checked") == "checked") {
                $(":checkbox").attr("checked", true);
            } else {
                $(":checkbox").attr("checked", false);
            }
        });

    });
</script> 
<script type="text/javascript">
    $(function() {
        $('.tree li:has(ul)').addClass('parent_li').find(' > span').attr('title', 'Collapse this branch');
        $('.tree li.parent_li > span').on('click', function(e) {
            var children = $(this).parent('li.parent_li').find(' > ul > li');
            if (children.is(":visible")) {
                children.hide('fast');
                $(this).attr('title', 'Expand this branch').find(' > i').addClass('icon-plus-sign').removeClass('icon-minus-sign');
            } else {
                children.show('fast');
                $(this).attr('title', 'Collapse this branch').find(' > i').addClass('icon-minus-sign').removeClass('icon-plus-sign');
            }
            e.stopPropagation();
        });
    });</script>
<script type="text/javascript">
    $(function() {
        $("#Event_Shop_CX").click(function() {
            document.getElementById("Event_Shop_CX_View").style.display = '';
            document.getElementById("Event_Clothes_CX_View").style.display = 'none';
        });
        $("#Event_Clothes_CX").click(function() {
            document.getElementById("Event_Shop_CX_View").style.display = 'none';
            document.getElementById("Event_Clothes_CX_View").style.display = '';
        });
    });</script>

<?php
$form = $this->beginWidget('CActiveForm', array(
    "id" => "findBookableForm",
    'enableAjaxValidation' => FALSE,
    'htmlOptions' => array('enctype' => 'multipart/form-data'),
        ));
$model = new BDynamicFormModel();
?>
<legend>
    <?php echo '我的未支付订单'; ?>|<small><?php echo $control->getAjaxLink(array('name' => '我的订单记录', 'id' => 'showMyBookingList'), array('paymentStatus' => 'paid')); ?></small>
</legend>

<table class="table table-hover">
    <thead>
        <tr>
            <th>
                <input type="checkbox"  id="selectAll"> 
            </th>
            <th><?php echo '序号'; ?></th>
            <th><?php echo '支付ID'; ?></th>
            <th><?php echo '产品名称'; ?></th>
            <th><?php echo '产品ID'; ?></th>
            <th><?php echo '单价（元）'; ?></th>
            <th><?php echo '数量'; ?></th>
            <th><?php echo '合计'; ?></th>
            <th><?php echo '操作'; ?></th>
        </tr> 
    </thead>
    <fieldset>
        <tbody>
            <?php
            $totalMoney = 0;
            $serial = 0;
            foreach ($view as $cartList) {
                if ($cartList instanceof BTreeList) {
                    $serial++;
                    $cartId = $cartList->getId();
                    $price = $cartList->getItem('price')->value;
                    $unit = $cartList->getItem('moneyUnit')->value;
                    $quantity = $cartList->getItem('quantity')->value;
                    $productName = $cartList->getItem('productName')->value;
                    $productId = $cartList->getItem('productId')->value;
                    $total = $price * $quantity;
                    if ($total != NULL)
                        $totalMoney += $total;
                }
                ?>
                <tr>

                    <td><label class="checkbox">
                            <input type="checkbox" name="checkbox[]" value="<?php echo $cartId; ?>"> 
                        </label></td>
                    <td> <?php echo $serial; ?> </td>
                    <td> <?php echo $cartId; ?> </td>
                    <td> <?php echo $productName; ?> </td>       
                    <td> <?php echo $productId; ?> </td>      
                    <td> <?php echo $price; ?> </td>   
                    <td> <?php echo $quantity; ?> </td>   
                    <td> <?php echo $total; ?> </td>   
                    <td>
                        <div class="row-fluid">                         
                            <?php
                            echo $control->getAjaxLink(array('name' => '修改', 'id' => 'showAddBookable'), array(
                                'htmlOptions' => array(
                                    'enctype' => 'multipart/form-data')
                            ));
                            ?>    
                            <?php
                            echo $control->getAjaxLink(array('name' => '删除', 'id' => 'showAddBookable'), array(
                                'htmlOptions' => array(
                                    'enctype' => 'multipart/form-data')
                            ));
                            ?> 
                        </div>                      
                    </td>
                </tr>
            <?php } ?>
            <tr>
                <td></td><td></td><td></td><td></td><td></td><td></td>
                <td><strong>总金额：</strong></td><td><?PHP echo $totalMoney; ?></td><td></td>
            </tr>
        </tbody>
    </fieldset>
</table>

<div class="row-fluid">
    <?php
    echo $control->getAjaxLink(array('name' => '删除', 'id' => 'deleteBookable'), array(
        'htmlOptions' => array(
            'class' => 'btn',
            'enctype' => 'multipart/form-data')));
    ?>
    <?php
    $paidMoney = $totalMoney;
    $paidCount = $totalCount;
    echo $control->getAjaxLink(array('name' => '确认支付', 'id' => 'payBooking'), array(
        'paidMoney' => $paidMoney,
        'paidCount' => $paidCount,
        'ajaxContainerId' => 'myModal2',
        'htmlOptions' => array(
            'enctype' => 'multipart/form-data',
            'class' => 'btn primary',
            'data-dismiss' => "modal",
            'aria-hidden' => 'true'
        ),
        'ajaxOptions' => array(
            'complete' => 'function(){$("#ajax-loaderdiv").hide();$("#myModal2").modal("show");}')
    ));
    ?>
</div>   
<div id="myModal2" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
<div><input type="hidden" name="curPageNo" value="1"></div>

<div class="pagination">  
    <ul>  
        <li class="active">
            <a href="javascript:void()">前一页</a>    </li>  
        <li class="active">
            <a href="javascript:void()">1</a>    </li>  
        <li class="active">
            <a href="javascript:void()">后一页</a>    </li>  
    </ul>  
</div>
<?php $this->endWidget(); ?>
